package com.intel.two.pojo.record.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.intel.two.pojo.record.InformationRecord;
import com.intel.two.pojo.record.recordbo.InformationRecordBo;
import com.intel.two.service.record.InformationRecordService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

@Component
@Scope("prototype") //设置多例
public class WebRecordListener extends AnalysisEventListener<InformationRecordBo> {
    @Autowired
    private InformationRecordService informationRecordService;
    @Override
    public void invoke(InformationRecordBo data, AnalysisContext analysisContext) {
        //属性拷贝
        InformationRecord informationRecord = new InformationRecord();
        BeanUtils.copyProperties(data,informationRecord);
        informationRecordService.recordAdd(informationRecord);

    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
